import React,{Component} from "react"

import{
    Image,
    Text,
    View,
    StyleSheet,
    Dimensions,
    TouchableHighlight
}from 'react-native'


const { width, height } = Dimensions.get('window');

const uiwidth=(width-30)/2

const styles=StyleSheet.create({
     warp:{
         width:'100%',
         padding:15,
         backgroundColor:'white',
         flexDirection:'row',
         justifyContent:'space-around',
         flexWrap:'wrap'
     },
     singui:{
         width:uiwidth,
         paddingTop:30,
         flexDirection:'column',
         alignItems:'center'
     },
     imgui:{
         width:'80%',
         height:40
     }
})

export default class Chartwarper extends Component{
    static navigationOptions={
        title:'报表',
        headerTitleStyle: {
        alignSelf:'center'
      },
    };

    state={
        data:''
    }

    async componentWillMount(){
        var data=await fetch(global.mainurl+'/bossHelper/getReport', {
                method: 'POST',
                 mode : 'cors',
                headers: {
                        'Content-Type': 'application/x-www-form-urlencoded'
                    },
                body: "sellerid="+global.sellerid
         })
         var result=await data.json()
         console.log(result)
         if(result.code==1){
             this.setState({
             data:result.data
             })
         }
         else{
             alert(result.msg)
         }
    }

    render(){
        return(
            <View style={styles.warp}>
            <TouchableHighlight onPress={()=>{this.props.navigation.navigate("Chartreport")}}>
            <View style={styles.singui}>
            <Image 
            style={styles.imgui}
            resizeMode='contain'
            source={require('../../img/editor.png')}/>
            <Text>对账单</Text>
            </View>
            </TouchableHighlight>

            <TouchableHighlight onPress={()=>{this.props.navigation.navigate("FoodChart")}}>
            <View style={styles.singui}>
            <Image 
            style={styles.imgui}
            resizeMode='contain'
            source={require('../../img/editor.png')}/>
            <Text>菜品统计</Text>
            </View>
            </TouchableHighlight>

            <TouchableHighlight onPress={()=>{this.props.navigation.navigate("RenGong",{data:this.state.data.labours})}}>
            <View style={styles.singui}>
            <Image 
            style={styles.imgui}
            resizeMode='contain'
            source={require('../../img/editor.png')}/>
            <Text>省人工</Text>
            </View>
            </TouchableHighlight>

            <TouchableHighlight onPress={()=>{this.props.navigation.navigate("XiaoShow",{data:this.state.data.marketSecondreports})}}>
            <View style={styles.singui}>
            <Image 
            style={styles.imgui}
            resizeMode='contain'
            source={require('../../img/editor.png')}/>
            <Text>增销售</Text>
            </View>
            </TouchableHighlight>

            <TouchableHighlight onPress={()=>{this.props.navigation.navigate("FoodChart",{data:this.state.data.marketShares})}}>
            <View style={styles.singui}>
            <Image 
            style={styles.imgui}
            resizeMode='contain'
            source={require('../../img/editor.png')}/>
            <Text>分享情况</Text>
            </View>
            </TouchableHighlight>

            <TouchableHighlight>
            <View style={styles.singui}>
            
            </View>
            </TouchableHighlight>

            </View>
        )
    }
}